package com.accp.restaurant.config;

import java.text.DecimalFormat;
import java.util.Date;
import java.util.Random;

public class StringUtil {
	
	public static String geneStrByArray(String[] strs,String joinStr){
		StringBuffer sbf = new StringBuffer();
		for(String s:strs){
			sbf.append(s).append(joinStr);
		}
		sbf.deleteCharAt(sbf.length()-1);
		return sbf.toString();
	}
	
	/**
	 * ��ݺ�׺������ļ���
	 * @param ext
	 * @return
	 */
	public static String geneFileNameByExt(String ext){
		Date date = new Date();
		long time = date.getTime();
		
		Random ran = new Random();
		int num = ran.nextInt(100000); 
		DecimalFormat df = new DecimalFormat("00000");
		String numStr = df.format(num);
		
		return time+numStr+"."+ext;
	}
	/**
	 * 生成随机数
	 * @return
	 */
	public static String geneOrderId(){
		Date date = new Date();
		long time = date.getTime();
		
		Random ran = new Random();
		int num = ran.nextInt(100000); 
		DecimalFormat df = new DecimalFormat("00000");
		String numStr = df.format(num);
		
		return time+numStr;
	}
	public static String setFileNameByExit(String Ext){
		Date date=new Date();
		long datelo=date.getTime();
		Random rd=new Random(1000000);
		long rdlong=rd.nextLong();
		String rdStr=rdlong+""+datelo;
		return rdStr+"."+Ext;
	}
}











